package cn.line5.seam.cms.article;

import java.util.List;

import cn.line5.seam.annotations.In;
import cn.line5.seam.annotations.Name;
import cn.line5.seam.annotations.Transaction;
import cn.line5.seam.db.IDGenerator;
import cn.line5.seam.db.PageResult;

@Name("articleService")
/**
 * <h1>LSEAM框架示例业务层实现类</h1>
 * 
 * @author Liu,yandong
 */
public class ArticleServiceImpl implements ArticleService{
	@In("articleDao")
	private ArticleDao articleDao;
	
	public List<ArticleVo> getList(){
		return this.articleDao.getList();
	}
	
	public PageResult<ArticleVo> getPageList(String currentPage){
		return this.articleDao.getPageList(currentPage);
	}
	
	public ArticleVo getArticle(String id){
		return this.articleDao.getArticle(id);
	}
	
	public ArticleVo getArticleVo(ArticleVo articleVo){
		return this.articleDao.getArticleVo(articleVo);
	}
	
	public boolean saveArticle(ArticleVo vo){
		if(vo.getArticleId() != null){
			return this.articleDao.modifyArticle(vo);
		}else{
			vo.setArticleId(IDGenerator.UUID());
			return this.articleDao.insertArticle(vo);
		}
	}

	public ArticleVo loginArticle(String loginAccount,String loginPassword){
		return this.articleDao.loginArticle(loginAccount,loginPassword);
	}
	@Transaction
	public boolean deleteArticle(String[] ids){
		boolean t = true;
		for(String id : ids){
			t &= this.articleDao.deleteArticle(id);
		}
		return t;
	}

}
